(function($) {
$.fn.smartFloat = function() {
	var position = function(element) {
		var thisw = document.documentElement.clientHeight - element.outerHeight() - 0;
		var top = element.position().top, pos = element.css("position");
		element.css({
						top: thisw
					});
		$(window).scroll(function() {
			var scrolls = $(this).scrollTop();
				if (window.XMLHttpRequest) {
					element.css({
						position: "fixed",
						top: thisw
					});
				} else {
					element.css({
						top: scrolls+thisw
					});
				}
		});
	};
	return $(this).each(function() {
		position($(this));
	});
};
})(jQuery);

/**
 * 阅读全文、显示摘要
 */
function change_show_mode(tag, thistag) {
	$thisTag = $("#" + thistag);
	if (tag == "showDetails") {
		
		$("#" + thistag+ " .p_excerpt .my_add_text").hide();
		$thisTag.parents('.perContentBox').find('.conBox').removeClass(
				"excerptBox").addClass("show_all_content");

		$thisTag.parents('.perContentBox').find('.conBox img').each(function() {
				$(this).attr('src',$(this).attr('data-original'));
		});

		$thisTag.children("div").children(".showDetails")
				.css("display", "none");
		$thisTag.children("div").children(".closeDetails").css("display",
				"block");
				$("#" + thistag+ " .p_excerpt img").show();
	} else {
		
		$("#" + thistag+ " .p_excerpt .my_add_text").show();
		$thisTag.parents('.perContentBox').find('.conBox').addClass(
				"excerptBox").removeClass("show_all_content");
		$('html,body').animate({
			scrollTop : $thisTag.parents('.perContentBox').offset().top - 40
		}, '10');
		$thisTag.children("div").children(".showDetails").css("display", "");
		$thisTag.children("div").children(".closeDetails").css("display",
				"none");
      $("#" + thistag+ " .p_excerpt img").hide();
	}
	return false;
}



// fixedbar scrolling
jQuery(document).ready(function($) {
     $(function() {
		 if( document.getElementById("widget_ads_slide") ){
			 var $fixedbar_side = $("#widget_ads_slide"), offset_sidebar = $fixedbar_side.offset();
         	 $(window).scroll(function () {
			   var scrollTop = document.body.scrollTop||document.documentElement.scrollTop;
               if (offset_sidebar.top < scrollTop){
                    $fixedbar_side.attr("style", "position:fixed; top:5px; width:260px;");
               }
               else $fixedbar_side.removeAttr("style");
			 });
		 }         
     });
});





/*
* Placeholder plugin for jQuery
* ---
* Copyright 2010, Daniel Stocks (http://webcloud.se)
* Released under the MIT, BSD, and GPL Licenses.
*/

(function(b) {
    function d(a) {
        this.input = a;
        a.attr("type") == "password" && this.handlePassword();
        b(a[0].form).submit(function() {
            if (a.hasClass("placeholder") && a[0].value == a.attr("placeholder")) a[0].value = ""
        })
    }
    d.prototype = {
        show: function(a) {
            if (this.input[0].value === "" || a && this.valueIsPlaceholder()) {
                if (this.isPassword) try {
                    this.input[0].setAttribute("type", "text")
                } catch(b) {
                    this.input.before(this.fakePassword.show()).hide()
                }
                this.input.addClass("placeholder");
                this.input[0].value = this.input.attr("placeholder")
            }
        },
        hide: function() {
            if (this.valueIsPlaceholder() && this.input.hasClass("placeholder") && (this.input.removeClass("placeholder"), this.input[0].value = "", this.isPassword)) {
                try {
                    this.input[0].setAttribute("type", "password")
                } catch(a) {}
                this.input.show();
                this.input[0].focus()
            }
        },
        valueIsPlaceholder: function() {
            return this.input[0].value == this.input.attr("placeholder")
        },
        handlePassword: function() {
            var a = this.input;
            a.attr("realType", "password");
            this.isPassword = !0;
            if (b.browser.msie && a[0].outerHTML) {
                var c = b(a[0].outerHTML.replace(/type=(['"])?password\1/gi, "type=$1text$1"));
                this.fakePassword = c.val(a.attr("placeholder")).addClass("placeholder").focus(function() {
                    a.trigger("focus");
                    b(this).hide()
                });
                b(a[0].form).submit(function() {
                    c.remove();
                    a.show()
                })
            }
        }
    };
    var e = !!("placeholder" in document.createElement("input"));
    b.fn.placeholder = function() {
        return e ? this: this.each(function() {
            var a = b(this),
            c = new d(a);
            c.show(!0);
            a.focus(function() {
                c.hide()
            });
            a.blur(function() {
                c.show(!1)
            });
            b.browser.msie && (b(window).load(function() {
                a.val() && a.removeClass("placeholder");
                c.show(!0)
            }), a.focus(function() {
                if (this.value == "") {
                    var a = this.createTextRange();
                    a.collapse(!0);
                    a.moveStart("character", 0);
                    a.select()
                }
            }))
        })
    }
})(jQuery);


function qqbox(position, type, outputType) {
	if (typeof(type) == 'undefined' || type == 'undefined') {
		type = '';
	}
	else {
		type = type + "_";
	}
	var adsWrap = document.getElementById("qq"+type+position);
	if (adsWrap) {
		adsWrap.style.display = "none";
	}
	try {
		var ads_position = eval("_qq_"+type+position);
		if (typeof(ads_position) != 'undefined') {
			//output type
            if (typeof(outputType) != 'undefined' && outputType == 'innerHTML') {
                adsWrap.innerHTML = ads_position;
            } else {
                document.write(ads_position);
            }
			if (adsWrap) {
				adsWrap.style.display = "block";
			}
		}
	}
	catch (e){
	}
}

$(function(){  
	// popup login box
	$(function() {
		function launch() {
			$('#loginDialog').lightbox_me({centered: true, onLoad: function() {
			$('#loginDialog').find('input:first').focus()
			}});
		}	
		$('.login-window').click(function() {
			$("#loader").lightbox_me({centered: true});
			setTimeout(launch, 100);
			return false;
		});

	});	
	$(function(){  
		$('.gotop').click(function(event){
			$('html, body').animate({scrollTop:0}, 300);
		});
	});
});


